import Vue from 'vue'
import Vuex from 'vuex'
import {
  SETUSERINFO
} from './mutations-type'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userinfo: null,
    menu: [],
  },
  getters: {
    permission(state) {
      return state.menu.map(item => item.path)
    },
  },
  mutations: {
    [SETUSERINFO](state, payload) {
      state.userinfo = payload
      state.menu = payload.menu
    }
  },
  actions: {},
  modules: {}
})